#include <stdio.h>

int main() {
    int i,j,m,n;
    int sum = 0;
    scanf("%d%d",&m,&n);
     int a[m][n];
     printf("\n");

       for (int i = 0; i < m; i++) 
        for ( j = 0; j < n; j++)
            scanf("%d",*(a+i)+j); 
    
     
    for (int i = 0; i < m; i++)
        for ( j = 0; j < n; j++) 
            sum += *(*(a+i)+j); 
    
    printf("三角元素的和为%d\n", sum);
    return 0;
}